package com.master.common.baseService;


import com.master.common.baseService.message.SendMessageService;
import com.master.constant.model.SysMessage;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;

/**
 * @author Heath.Que
 * @version 1.0
 * @classname BaseServiceImpl
 * @description TODO
 * @Date 2021/5/31 16:21
 **/
public abstract class BaseServiceImpl {

    @Autowired
    private SendMessageService sendMessageService;

    public Logger getLogger(){
        return LoggerFactory.getLogger(this.getClass());
    }


    /**
     * 根据传入的队列名、路由名将消息放入对应的消息队列
     * @param message
     * @param messageType
     * @param messageRouting
     * @return
     */
    public Boolean sendMessage(SysMessage message, String messageType, String messageRouting){
        boolean mark = false;
        try {
            //将消息体放入消息队列
            sendMessageService.sendDirectMessage(message, messageType, messageRouting);
            mark = true;
        }catch (Exception e){
            getLogger().error(e.getMessage());
        }

        return mark;
    }

}
